﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Description;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace RL.Wcf
{
    public static class ServiceHostX
    {
        public static ServiceEndpoint Open<TContractInterface>(this ServiceHost host, Binding binding, string location)
        {
            var endPoint = host.AddServiceEndpoint(
                    typeof(TContractInterface), binding,
                    location);
            host.Open();
            return endPoint;
        }

        public static ServiceEndpoint OpenWithBasicHttpBinding<TContractInterface>(this ServiceHost host, string location)
        {
            var endPoint = host.AddServiceEndpoint(
                    typeof(TContractInterface), new BasicHttpBinding(),
                    location);
            host.Open();
            return endPoint;
        }
    }
}
